package com.eam.asset.file.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.eam.asset.file.vo.AssetOther.AssetOtherAddVo;
import com.eam.asset.file.vo.AssetOther.AssetOtherPutVo;
import com.eam.asset.file.vo.AssetOther.AssetOtherQueryVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.eam.common.annotation.Log;
import com.eam.common.core.controller.BaseController;
import com.eam.common.core.domain.AjaxResult;
import com.eam.common.enums.BusinessType;
import com.eam.asset.file.domain.AssetOther;
import com.eam.asset.file.service.IAssetOtherService;
import com.eam.common.utils.poi.ExcelUtil;
import com.eam.common.core.page.TableDataInfo;

/**
 * 其他资产档案(广告位等)Controller
 *
 * @author tzf
 * @date 2023-10-31
 */
@RestController
@RequestMapping("/asset/other")
@Validated
@Api(tags = "其他资产类型控制器")
public class AssetOtherController extends BaseController {
    private final IAssetOtherService assetOtherService;

    @Autowired
    public AssetOtherController(IAssetOtherService assetOtherService) {
        this.assetOtherService = assetOtherService;
    }

    /**
     * 查询其他资产档案(广告位等)列表
     */
    @PreAuthorize("@ss.hasPermi('asset:other:list')")
    @GetMapping("/list")
    @ApiOperation(value = "获取资产列表")
    public TableDataInfo list(AssetOtherQueryVo assetOther) {
        startPage();
        List<AssetOther> list = assetOtherService.selectAssetOtherList(assetOther);
        return getDataTable(list);
    }

    /**
     * 导出其他资产档案(广告位等)列表
     */
    @PreAuthorize("@ss.hasPermi('asset:other:export')")
    @Log(title = "其他资产档案(广告位等)", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation(value = "导出Excel")
    public void export(HttpServletResponse response, AssetOtherQueryVo assetOther) {
        List<AssetOther> list = assetOtherService.selectAssetOtherList(assetOther);
        ExcelUtil<AssetOther> util = new ExcelUtil<AssetOther>(AssetOther.class);
        util.exportExcel(response, list, "其他资产档案(广告位等)数据");
    }

    /**
     * 获取其他资产档案(广告位等)详细信息
     */
    @PreAuthorize("@ss.hasPermi('asset:other:query')")
    @GetMapping(value = "/{otherId}")
    @ApiOperation(value = "查询其他类型资产")
    public AjaxResult getInfo(@PathVariable("otherId") String otherId) {
        return success(assetOtherService.selectAssetOtherByOtherId(otherId));
    }

    /**
     * 新增其他资产档案(广告位等)
     */
    @PreAuthorize("@ss.hasPermi('asset:other:add')")
    @Log(title = "其他资产档案(广告位等)", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation(value = "添加其他类型资产")
    public AjaxResult add(@RequestBody AssetOtherAddVo assetOther) {
        return toAjax(assetOtherService.insertAssetOther(assetOther));
    }

    /**
     * 修改其他资产档案(广告位等)
     */
    @PreAuthorize("@ss.hasPermi('asset:other:edit')")
    @Log(title = "其他资产档案(广告位等)", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation(value = "修改其他类型资产")
    public AjaxResult edit(@Validated @RequestBody AssetOtherPutVo assetOther) {
        return toAjax(assetOtherService.updateAssetOther(assetOther));
    }

    /**
     * 删除其他资产档案(广告位等)
     */
    @PreAuthorize("@ss.hasPermi('asset:other:remove')")
    @Log(title = "其他资产档案(广告位等)", businessType = BusinessType.DELETE)
    @DeleteMapping("/{otherIds}")
    @ApiOperation(value = "删除其他类型资产")
    public AjaxResult remove(@PathVariable String[] otherIds) {
        return toAjax(assetOtherService.deleteAssetOtherByOtherIds(otherIds));
    }
}
